/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package util;

import beans.Musica;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author nMoncho
 */
public class MusicasTableModel extends AbstractTableModel{
    
    private ArrayList<Musica> musicas;

    public MusicasTableModel(ArrayList<Musica> musicas){
        this.musicas = musicas;
    }

    @Override
    public int getRowCount() {
        return musicas.size();
    }

    @Override
    public int getColumnCount() {
        return 1;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return musicas.get(rowIndex).getNombre();
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        musicas.get(rowIndex).setNombre((String)aValue);
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return true;//Todas deben ser editables
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        return String.class;
    }

    @Override
    public String getColumnName(int column) {
        return "Nombre de Musica";
    }

}
